<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>题库管理</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap.min.css">
    <script  src="${pageContext.request.contextPath}/static/js/jquery-3.6.0.min.js"></script>
</head>
<style>
    td {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px; /* 根据需要设置宽度 */
    }
</style>
<body>
<div class="container">
    <h1 class="mt-5">题库管理</h1>

    <!-- 导航菜单 -->
    <div class="mt-4 mb-4">
        <ul class="nav nav-pills">
            <li class="nav-item">
                <a class="nav-link" href="${pageContext.request.contextPath}/teacher/home">首页</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="${pageContext.request.contextPath}/teacher/examManage">试卷管理</a>
            </li>
            <li class="nav-item">
                <a class="nav-link active" href="#">题库管理</a>
            </li>
        </ul>
    </div>

    <!-- 添加新单选题 -->
    <div class="card mt-4">
        <div class="card-header">
            <h3>添加新单选题</h3>
        </div>
        <div class="card-body">
            <form id="addQuestionForm">
                <div class="mb-3">
                    <label for="questionTitle" class="form-label">试题标题</label>
                    <input type="text" class="form-control" id="questionTitle" name="title" required>
                </div>
                <div class="mb-3">
                    <label for="questionAnswer" class="form-label">正确答案</label>
                    <select class="form-control" id="questionAnswer" name="answer" required>
                        <option value="A">A</option>
                        <option value="B">B</option>
                        <option value="C">C</option>
                        <option value="D">D</option>
                    </select>
                </div>
                <div class="mb-3">
                    <label for="optionA" class="form-label">选项 A</label>
                    <input type="text" class="form-control" id="optionA" name="optionA" required>
                </div>
                <div class="mb-3">
                    <label for="optionB" class="form-label">选项 B</label>
                    <input type="text" class="form-control" id="optionB" name="optionB" required>
                </div>
                <div class="mb-3">
                    <label for="optionC" class="form-label">选项 C</label>
                    <input type="text" class="form-control" id="optionC" name="optionC" required>
                </div>
                <div class="mb-3">
                    <label for="optionD" class="form-label">选项 D</label>
                    <input type="text" class="form-control" id="optionD" name="optionD" required>
                </div>
                <button type="submit" class="btn btn-success">添加试题</button>
            </form>
        </div>
    </div>

    <!-- 试题列表 -->
    <div class="card mt-4">
        <div class="card-header d-flex justify-content-between align-items-center">
            <h3>试题列表</h3>
            <div>
                <label for="searchQuestion"></label>
                <input type="text" id="searchQuestion" class="form-control" placeholder="按标题搜索试题">
            </div>
        </div>
        <div class="card-body">
            <table class="table table-striped" id="questionTable">
                <thead>
                <tr>
                    <th>题目编号</th>
                    <th>题目标题</th>
                    <th>正确答案</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <!-- 试题数据会通过AJAX动态加载 -->
                </tbody>
            </table>
        </div>
    </div>


    <%--编辑问题的模态框--%>
    <div class="modal fade" id="editQuestionModal" tabindex="-1" aria-labelledby="editQuestionModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="editQuestionModalLabel">编辑试题</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <form id="editQuestionForm">
                        <input type="hidden" id="editQuestionId">
                        <div class="mb-3">
                            <label for="editQuestionTitle" class="form-label">试题标题</label>
                            <input type="text" class="form-control" id="editQuestionTitle" required>
                        </div>
                        <div class="mb-3">
                            <label for="editCorrectOption" class="form-label">正确答案</label>
                            <select class="form-control" id="editCorrectOption" required>
                                <option value="A">A</option>
                                <option value="B">B</option>
                                <option value="C">C</option>
                                <option value="D">D</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label for="editOptionA" class="form-label">选项 A</label>
                            <input type="text" class="form-control" id="editOptionA" required>
                        </div>
                        <div class="mb-3">
                            <label for="editOptionB" class="form-label">选项 B</label>
                            <input type="text" class="form-control" id="editOptionB" required>
                        </div>
                        <div class="mb-3">
                            <label for="editOptionC" class="form-label">选项 C</label>
                            <input type="text" class="form-control" id="editOptionC" required>
                        </div>
                        <div class="mb-3">
                            <label for="editOptionD" class="form-label">选项 D</label>
                            <input type="text" class="form-control" id="editOptionD" required>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="saveQuestionBtn">保存</button>
                </div>
            </div>
        </div>
    </div>

</div>

<script src="${pageContext.request.contextPath}/static/js/teacher/questionBank.js"></script>
<script src="${pageContext.request.contextPath}/static/js/bootstrap.bundle.min.js"></script>
</body>
</html>
